package com.ruoyi.web.controller.schoolDistrict;

import com.ruoyi.domain.School;
import com.ruoyi.service.ISchoolService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @version 1.0
 * @ClassName
 * @Author DELL
 * @Date 2020/6/22 16:16
 **/

@Controller
@RequestMapping("/wechat/school")
public class WechatSchoolDistrictController {

    private final String prefix = "phone/school-district";

    @Autowired
    private ISchoolService schoolService;

    /**
     * 跳转：首页
     *
     **/
    @GetMapping("/index")
    public String toIndex()
    {
        return prefix + "/index";
    }


    /**
     * 跳转：学区地图（百度）
     *
     **/
    @GetMapping("/map_bd")
    public String toIndexBd(ModelMap map)
    {
        List<School> schoolMapList = schoolService.getSchoolMapList(new School());
        map.put("markerData",schoolMapList);
        return prefix + "/index_bd";
    }


    /**
     * 跳转：学区地图（谷歌）
     *
     **/
    @GetMapping("/map_gd")
    public String toIndexGd()
    {
        return prefix + "/index_gd";
    }

    /**
     * 跳转：招生咨询
     *
     **/
    @GetMapping("/information/index")
    public String toInformationIndex()
    {
        return prefix + "/information";
    }

    /**
     * 跳转：学校列表
     *
     **/
    @GetMapping("/schoolList/index")
    public String toSchoolList()
    {
        return prefix + "/schoolList";
    }

    /**
     * 跳转：问题反馈
     *
     **/
    @GetMapping("/question/index")
    public String toQuestionIndex()
    {
        return prefix + "/question";
    }


    @RequestMapping("/getSchoolList")
    @ResponseBody
    public ResponseEntity getSchoolList(School school){
        return ResponseEntity.ok(schoolService.selectSchoolList(school));
    }



    @PostMapping("/getSchoolMapList")
    @ResponseBody
    public ResponseEntity getSchoolMapList(School school){
        return ResponseEntity.ok(schoolService.getSchoolMapList(school));
    }

    @PostMapping("/getSchoolDetailInMap")
    @ResponseBody
    public ResponseEntity getSchoolDetailInMap(School school){
        return ResponseEntity.ok(schoolService.getSchoolMapList(school));
    }



}
